package com.framework.sog.bs.impl;

import java.net.InetAddress;

import com.framework.bas.bs.IPlmBasBS;
import com.framework.bas.util.UtilDatetime;
import com.framework.bas.util.UtilMessage;
import com.framework.sog.bs.IPlmSogBS;
import com.framework.sog.util.PlmSogConstant;
import com.framework.sog.vo.BasLogLogin;
import com.framework.sog.vo.HpSogServiceVO;
import com.framework.sog.vo.HpSogTaskVO;

public class PlmSogBSImpl implements IPlmSogBS {
	
	private IPlmBasBS plmBasBS;

	public IPlmBasBS getPlmBasBS() {
		return plmBasBS;
	}

	public void setPlmBasBS(IPlmBasBS plmBasBS) {
		this.plmBasBS = plmBasBS;
	}

	public void createUserSysLog(BasLogLogin param) {
		
	}

	public void txNewServiceLog(HpSogServiceVO param) {
	}

	public void txNewTaskLog(HpSogTaskVO param, String operFlag) {
		if(operFlag.equals(PlmSogConstant.SOG_TASK_INSERT)){
			String id = this.getPlmBasBS().txNewStringKey(PlmSogConstant.SEQ_SOG_SERVICE, true);
			param.setId(id);
		    param.setStartDate(UtilDatetime.getDateString());
		    param.setStartTime(UtilDatetime.getTimeString());
		    try{
		    	param.setLogonIp(InetAddress.getLocalHost().getHostAddress());
		    }catch(Exception e){
		    	param.setLogonIp("127.0.0.1");
		    }		    
		    Object[] objs = new Object[] {param.getTaskName()};
			String info = UtilMessage.getMessage(PlmSogConstant.MSG_0003, objs);
		    param.setRemark(info);
		    this.getPlmBasBS().save(param);
		}else{
			param.setEndDate(UtilDatetime.getDateString());
		    param.setEndTime(UtilDatetime.getTimeString());
		    this.getPlmBasBS().update(param);
		}		
	}

}
